<!DOCTYPE html>
<html lang="en">
<script src="sockjs.min.js"></script>

<head>
    <meta charset="UTF-8">
    <title>WebSocket client</title>
</head>

<body>
    <button onclick="sock.onopen()">connect</button>
    <button onclick="close()">close</button>
    <button onclick="sendMsg()">sendMsg</button>
</body>

<script type="text/javascript">
    var sock = new SockJS('http://localhost:8080/chat/123');
    sock.onopen = function () {
        console.log('open');
        sock.send('test');
    };

    sock.onmessage = function (e) {
        console.log('message', e.data);
        sock.close();
    };

    sock.onclose = function () {
        console.log('close');
    };
</script>

</html>